package be.bonamis.umpire.ui.client;

import java.util.logging.Logger;

import be.bonamis.umpire.ui.client.activities.LoginActivity;
import be.bonamis.umpire.ui.client.places.LoginPlace;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.google.inject.Inject;

public class AppActivityMapper implements ActivityMapper {

	private final ClientFactory clientFactory;

	private final Logger LOGGER = Logger.getLogger("ActivityMapper");

	@Inject
	public AppActivityMapper(ClientFactory clientFactory) {		
		this.clientFactory = clientFactory;
	}

	@Override
	public Activity getActivity(Place place) {
		LOGGER.info("Received place change in ActivityManager: " + place.toString());
		if (place instanceof LoginPlace)
			return new LoginActivity((LoginPlace) place, clientFactory);
		return null;
	}
}
